{extend name="template/base" /}
{block name="nav"}{/block}
{block name="content"}
<div class="page-container">
    <form class="form form-horizontal" id="form" method="post" action="{:\\think\\Url::build('confirmChangeState')}">
        <input type="hidden" name="id" value="{$vo.id ?? ''}">
        <input type="hidden" name="id" value="{$vo.id ?? ''}">
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">订单编号：</label>
            <div class="formControls col-xs-6 col-sm-6">
                {$vo.number??''}
            </div>
            <div class="col-xs-3 col-sm-3">{$vo.unit_sum??0}件商品，共计{$vo.total_fee??0}</div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">商品列表：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <table class="table table-border">
                    <tbody>
                    {volist name="goods" id="good" key="k"}
                    <tr>
                        <td>{$k??''}</td>
                        <td>
                            <img src="">
                        </td>
                        <td>{$good.name}</td>
                        <td>x{$good.sum}</td>
                        <td>￥{$good.price*$good.sum}</td>
                    </tr>
                    {/volist}
                    </tbody>
                </table>
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">联系方式：</label>
            <div class="formControls col-xs-6 col-sm-6 skin-minimal">
                {$address['name']??''}：{$address['phone']??'无'}
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">配送地址：</label>
            <div class="formControls col-xs-6 col-sm-6 skin-minimal">
                {$address['province']??''}/
                {$address['city']??''}/
                {$address['area']??''}/
                {$address['detailed_address']??''}
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>

        <input type="hidden" name="new_state" id="new_state">
        {if condition="$vo.state == 'paid'"}
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">等待发货：</label>
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <button type="button" onclick="shipment(this,'您确定已发货了？','received')" class="btn btn-primary radius">&nbsp;&nbsp;确认发货&nbsp;&nbsp;</button>
                <button type="button" class="btn btn-default radius ml-20" onClick="layer_close();">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
            </div>
        </div>
        {/if}
        {if condition="$vo.state == 'refund'"}
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">申请退款：</label>
            <div class="formControls col-xs-6 col-sm-6 skin-minimal">
                <button type="button" onclick="shipment(this,'您确定同意退款?','refunded')" class="btn btn-primary radius">&nbsp;&nbsp;确认退款&nbsp;&nbsp;</button><br/><br/>
                <button type="button" onclick="shipment(this,'您确定拒绝退款?','refundback')" class="btn btn-default radius">&nbsp;&nbsp;拒绝退款&nbsp;&nbsp;</button>
                <!--<textarea name="back_comment" placeholder="拒绝退款事由"></textarea><br/><br/>-->
                <!--<button type="button" class="btn btn-default radius ml-20" onClick="layer_close();">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>-->
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        {/if}
    </form>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__LIB__/Validform/5.3.2/Validform.min.js"></script>
<script>
    $(function () {
        $("[name='status'][value='{$vo.status ?? '1'}']").attr("checked",true);

        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        $("#form").Validform({
            tiptype:2,
            ajaxPost:true,
            showAllError:true,
            callback:function(ret){
                ajax_progress(ret);
            }
        });
    })
    function shipment(obj,msg,state) {
        $('#new_state').val(state);
        layer.alert(msg, {
            btn: ['确定', '取消'] //按钮
        }, function (i) {
            $(obj).submit();
            layer.close(i);
        });
    }
</script>
{/block}